﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using HitachiApp.Model.Projects;

namespace HitachiApp.View.Projects
{
    public partial class ProjectManageView : UserControl
    {
        public ProjectManageView()
        {
            InitializeComponent();
        }

        private void project_manage_tree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
        }

        private void update_project_Click(object sender, RoutedEventArgs e)
        {
            ProjectManageViewModel model = DataContext as ProjectManageViewModel;
            model.UpdateCurrentSelected();
        }

        private void project_manage_tree_help_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
        }

        private void project_moveto_help_Click(object sender, RoutedEventArgs e)
        {
            ProjectManageViewModel model = DataContext as ProjectManageViewModel;
            if (model.CurrentSelectedHelp != null)
                model.MoveSelectedItemTo(model.CurrentSelectedHelp);
        }

        private void project_movefrom_help_Click(object sender, RoutedEventArgs e)
        {
            ProjectManageViewModel model = DataContext as ProjectManageViewModel;
            if (model.CurrentSelected != null)
                model.MoveSelectedItemTo(model.CurrentSelected);
        }

        private void refresh_Click(object sender, RoutedEventArgs e)
        {
            ProjectManageViewModel model = DataContext as ProjectManageViewModel;
            model.Load(null);
        }

        private void project_manage_tree_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            TreeView tv = sender as TreeView;
            ProjectManageViewModel model = DataContext as ProjectManageViewModel;
            model.CurrentSelected = tv.SelectedItem as ProjectManageItem;
        }

        private void project_manage_tree_help_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            TreeView tv = sender as TreeView;
            ProjectManageViewModel model = DataContext as ProjectManageViewModel;
            model.CurrentSelectedHelp = tv.SelectedItem as ProjectManageItem;
        }
    }
}
